package com.gaogzhen.juc.visibility;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;

@Slf4j(topic = "c.Test02")
public class Test02 {
    volatile static boolean run = true;

    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(() -> {
            while (run) {
                // 循环体
            }
        });
        log.debug("t线程开始运行...");
        t.start();
        TimeUnit.SECONDS.sleep(1);
        log.debug("线程t退出循环...");
        run = false;
    }
}
